//
//  ZPTVisitorTController.swift
//  weibo
//
//  Created by zhangpeng on 16/4/16.
//  Copyright © 2016年 zhangpeng. All rights reserved.
//

import UIKit

class ZPTVisitorTController: UITableViewController {

    //判断用户是否登录，
    var isLogin:Bool = ZPUserAccountTools.sharedTools.isLogin
    //访客试图
    var visitorView:ZPVisitorView?
    
    override func loadView() {
        
  
        isLogin ? super.loadView() : setupVisitorView()
//            super.loadView()
//        }else{
//        
//            setupVisitorView()
//            
//        }
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
       // MARK: -  监听事件
    @objc private func login(){
    
        let oauthVC = ZPOauthViewController()
        
        presentViewController(UINavigationController(rootViewController: oauthVC), animated:true, completion: nil)
        
    }
    
    //设置导航栏
    private func setupNav(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    
    }
    
     // MARK: -  设置视图
    private func setupVisitorView(){
    
        setupNav()
        
        visitorView = ZPVisitorView()
        
        visitorView?.visitorClosure = {
        self.login()
            
        }
        view = visitorView
    }
    
}
